﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using XuanXiang.Infrastructure.Attr;
using XuanXiang.Infrastructure.Dto.Request;
using XuanXiang.Infrastructure.Dto.Request.Merchant;
using XuanXiang.Infrastructure.Dto.Response.Promote;
using XuanXiang.Service.Interface;

namespace XuanXiang.Api.Admin.Controllers
{

    [ApiGroup("Admin(管理员模块)")]
    public class PromoteController : BaseController
    {
        private readonly I_Pomote_Service _pomote_Service;

        public PromoteController(I_Login_Service login_Service,I_Pomote_Service pomote_Service) : base(login_Service)
        {
            _pomote_Service = pomote_Service;
        }


        /// <summary>
        /// 获取活动列表{page,limit,key}
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> Get_Promotes(int page = 1, int limit = 10, string? key = "",bool? isEnd=false) {
            var result = await _pomote_Service.Get_Promotes(new Fenye_Dto() { 
            page=page,
            limit=limit,
            key=key??"",
            isEnd=isEnd
            });

            return Ok(result);
        }



        /// <summary>
        /// 停止活动{id}
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IActionResult> Stop_Promote(Promotes_Dto dto) {
            var result = await _pomote_Service.Stop_Promote(dto.id);
            return Ok(result);
        }
    }
}
